#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
bool vis[1000010];
signed main(){
  IOS;
  freopen("color.in","r",stdin);
  freopen("color.out","w",stdout);
  int t;
  cin >> t;
  while(t--){
    int n;
    cin >> n;
    int ans = 0;
    while(n--){
      int x;
      cin >> x;
      if(vis[x]) ans += x;
      vis[x] = 1;
    }
    cout << ans << "\n";
  }
  return 0;
}